package com.kim.smartring.db.dao;

import java.util.List;

import android.content.Context;

import com.kim.smartring.db.model.SleepRecord;
import com.kim.smartring.utils.DateUtils;

public class SleepRecordDao extends BaseDao<SleepRecord, String> {

	public SleepRecordDao(Context context) {
		super(context);
	}

	public List<SleepRecord> getUnSyncSleepRecords() {
		String strWhere = " sRecordTime < "
				+ DateUtils.getCurrentDayStartTime() + " and sSyncState=0";
		return findAllByWhere(SleepRecord.class, strWhere);
	}

	public void updateSyncState(List<SleepRecord> sleepRecords) {
		if (sleepRecords == null || sleepRecords.size() == 0) {
			return;
		}
		for (SleepRecord record : sleepRecords) {
			record.setsSyncState(1);
			update(record);
		}
	}
}
